Skip to content

[4.x] Add token-based security for cart loading#4207

Draft
lukeholder wants to merge 4 commits into4.xfrom
feature/load-cart-token-4x
Draft

[4.x] Add token-based security for cart loading#4207
lukeholder wants to merge 4 commits into4.xfrom
feature/load-cart-token-4x

Conversation

@lukeholder
Copy link
Member

  • Require valid token or logged-in cart owner to load a cart via load-cart action
  • Add cartLinkExpiry setting (default 24 hours) for token expiration
  • Add getLoadCartUrl() method to Carts service that generates secure token URLs
  • Update Order::getLoadCartUrl() to return secure token URL
  • Add email challenge flow for cart recovery when token is missing/expired
  • Register commerce_cart_recovery system message for recovery emails
  • Add _cart/email-challenge.twig and email-sent.twig templates
  • Carts that have no email/custom associated and not address information will load without needing to check token etc.

- Add secure token validation to load-cart action
  - Carts with email/addresses require valid token or owner authentication
  - Carts without sensitive data can load without token
  - Add email challenge flow for unauthenticated cart recovery
  - Register commerce_cart_recovery system message for recovery emails
  - Add cartLinkExpiry setting (default 24 hours)
  - Add getLoadCartUrl() to Carts service for generating secure URLs
@lukeholder lukeholder changed the title Add token-based security for cart loading [4.x] Add token-based security for cart loading Jan 21, 2026
@rlarabee
Copy link

rlarabee commented Jan 25, 2026

Take a look at _getCart() in CartController.php as well because it is called by actionUpdateCart() and actionComplete() and any other cart modification actions, make sure the same validation is applied. I am not sure how this will affect the over all functionality, but from a cryptographic standpoint, for the generateCartNumber, I would move to something like bin2hex(random_bytes(16)).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants